//
//  GLMonthChargeViewController.m
//  Runone
//
//  Created by ekkaLyn on 2017/4/21.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "GLMonthChargeViewController.h"
#import "GLTollStationDataCell.h"
#import "GLTollStationSectionHeaderView.h"
#import "UIView+Addition.h"
#import "MJRefresh.h"
#import "EKPopMenuView.h"
#import "NSDate+Extension.h"
//请求
#import "RequestHelper.h"
//传参
#import "RequestGinsengModel.h"
//返回值
#import "RequestOutginseng.h"

@interface GLMonthChargeViewController ()

@property (nonatomic, strong)GLTollStationSectionHeaderView *stationHeaderV;
@property (nonatomic, strong)EKPopMenuView *dateMenuV;


@end



//////////////////////
////内网开发专用 登录接口
//#define GetLOGINURL @"http://192.168.1.200:8088/OAuth/Token"
////内网开发专用 API URL
//#define GetAPIURL @"http://192.168.1.200:8090"


//////***收费数据当月每天收费金额跟车流量界面***///////

static NSString *cellID = @"tollStationDataCell";
@implementation GLMonthChargeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpNavigationbar];
    [self setUpTableView];
    //[self caculateMenuData];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self setUpDefaultValue];
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.dateMenuV hideWithAnimation:NO];
}



//- (void) requsetBDMTollEventTypeDefineInfo {
//    RequestHelper *requestHelper               = [[RequestHelper alloc] init];
//    RequestGinsengModel *getNewAllHighWayModel = [[RequestGinsengModel alloc] init];
//    getNewAllHighWayModel.URL                  = GetEventDataURL;
//    getNewAllHighWayModel.DataValue            = @"";
//    getNewAllHighWayModel.UpdatedTime          = @"2000-01-01 01:00:00";
//    getNewAllHighWayModel.SystemCode           = @"GuangleHighway";
//    getNewAllHighWayModel.MethodName           = @"GetAllTollEventType";
//    requestHelper.block=^(RequestOutginseng *requestOutginseng,id dataValueModel){
//        if ([requestOutginseng.Code isEqualToString:@"001"]) {
//            [self drawAllPile];
//            [self drawPileNO];
//            [self loadAnnotationView];
//            [self.currentEventBtn setTitle:[NSString stringWithFormat:@"当前事件：%lu",(unsigned long)_dataArray.count] forState:UIControlStateNormal];
//            //            [SVProgressHUD showSuccessWithStatus:@"加载完毕"];
//            [SVProgressHUD dismiss];
//        }else {
//            [SVProgressHUD showErrorWithStatus:@"网络请求失败,请稍后再试"];
//        }
//    };
//    [requestHelper RequestGinsengModel:getNewAllHighWayModel andPushController:self];
//}
//






///设置导航条
- (void) setUpNavigationbar {
    UILabel *label                = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
    label.text                    = @"江口收费数据";
    label.textAlignment           = NSTextAlignmentCenter;
    label.textColor               = [UIColor whiteColor];
    self.navigationItem.titleView = label;
}

//设置tableView
- (void) setUpTableView {
    [self.tableView registerNib:[UINib nibWithNibName:@"GLTollStationDataCell" bundle:nil] forCellReuseIdentifier:cellID];
    self.tableView.separatorStyle  = UITableViewCellSeparatorStyleNone;
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    self.tableView.mj_footer.hidden = YES;
    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    self.tableView.delegate   = self;
    self.tableView.dataSource = self;
}

///设置日期
- (void)setUpDefaultValue {
    NSDate *nowDate = [NSDate date];
    NSString *dateStr = [nowDate stringWithFormat:@"yyyy-MM-dd"];
    NSArray *arr = [dateStr componentsSeparatedByString:@"-"];
    NSString *yMonthStr = [NSString stringWithFormat:@"%@年%@月",arr[0],arr[1]];
    [self.stationHeaderV refreshBtnTitleString:yMonthStr];
}

///设置菜单
- (void) setUpPopMenuView{
    
     _dateMenuV = [[EKPopMenuView alloc] initEKPopViewWithFrame:CGRectMake(8,CGRectGetMaxY(self.stationHeaderV.frame), ([UIScreen mainScreen].bounds.size.width * 2 / 5), 44 * 5) annimationFormLeft:YES];
   
    _dateMenuV.itemNameArray = _popMenuDataArr;
    _dateMenuV.fontSize  = 16.0f;
    _dateMenuV.fontColor = [UIColor whiteColor];
    [_dateMenuV dismissHandler:^(BOOL isCanceled, NSInteger row) {
        self.stationHeaderV.isSelectCanderBtn = NO;
        [self.stationHeaderV refreshBtnTitleString:_popMenuDataArr[row]];
    }];
    [_dateMenuV show];
}

#pragma mark - Table view data source设置数据源

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
    GLTollStationDataCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    cell.isShowRightArrow = NO;

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 50;
}

//
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    __weak __typeof(&*self)weakSelf = self;
    _stationHeaderV = [[GLTollStationSectionHeaderView alloc]initGLStationSectionView:CGRectMake(0, 0, self.view.width, 50)];
    _stationHeaderV.btnClickBlock = ^(BOOL show){
        if (show) {
             [weakSelf setUpPopMenuView];
            
        }
    };
    return _stationHeaderV;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 110;
}


@end
